﻿using System;
using System.Windows.Input;

namespace DynamicVm.Wpf
{
    public class CommandFactory : ICommandFactory
    {
        public ICommand Command(Action execute, Func<bool> canExecute = null)
        {
            return new DelegateCommand(execute, canExecute);
        }

        public ICommand Command<T>(Action<T> execute, Func<T, bool> canExecute = null)
        {
            return new DelegateCommand<T>(execute, canExecute);
        }

        private CommandFactory()
        {
        }

        public static ICommandFactory Current
        {
            get { return _factory ?? (_factory = new CommandFactory()); }
        }

        private static ICommandFactory _factory;
    }
}
